package com.hombio.controller;

import java.io.UnsupportedEncodingException;

import org.codehaus.jettison.json.JSONException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.hombio.UIBean.Storage;
import com.hombio.UIBean.StorageItem;
import com.hombio.service.MedicineMSService;


@Controller
public class MedicineStorageController {

	@Autowired
	MedicineMSService medicineMSService;
	
	
	//201707230000500038190166，清肺止咳散，兽药字190585157，兴达药业，020-61950666
	@RequestMapping("/ms/traceCode/process/{supplierId}")
	@ResponseBody
	public StorageItem processTraceCode(@RequestBody StorageItem storage, @PathVariable Integer supplierId){
		return medicineMSService.processTraceCode(storage.getTraceCode(),supplierId);
	}
	
	@RequestMapping("/ms/save/{employeeId}/{supplierId}")
	@ResponseBody
	public String saveStorageRecord(@PathVariable Integer employeeId,@PathVariable Integer supplierId,
			@RequestBody Storage storages){
		medicineMSService.saveStorageRecord(employeeId, supplierId, storages);
		return "success";
	}
	
	@RequestMapping("/ms/price")
	public String goToMedicinePrice(){
		return "medicine-storage-price";
	}
}
